{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# dataExchange_attributeConstruction\n",
    "# -*- coding:utf-8 -*-\n",
    "# 目标：属性构造和洗浴事件筛选\n",
    "# 需要构造的属性如下：\n",
    "#热水事件\t起始数据编号\t终止数据编号\t开始时间（begin_time）\n",
    "# 根据日志判断是否为洗浴（1表示是，0表示否）\t洗浴时间点\t总用水时长（w_time）\t\n",
    "# 总停顿时长（w_pause_time）\t平均停顿时长（avg_pause_time）\t停顿次数（pause）\t\n",
    "# 用水时长（use_water_time）\t用水/总时长（use_water_rate）\t总用水量（w_water）\n",
    "# 平均水流量（water_rate）\t水流量波动（flow_volatility）\t停顿时长波动（pause_volatility）\n",
    "\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from pandas import DataFrame,Series\n",
    "\n",
    "\n",
    "inputfile = 'dataExchange_divideEvent.xlsx'\n",
    "data = pd.read_excel(inputfile)\n",
    "# len(data)# 7696\n",
    "inputfile1 = 'data_guiyue.xlsx'\n",
    "data1 = pd.read_excel(inputfile1)\n",
    "x = pd.merge(data1,data[[u'事件编号']],left_index = True, right_index=True,how='outer')\n",
    "# 连接'data_guiyue.xlsx'和 'dataexchange_divideEvent.xlsx'的后两列,因为，属性规约里面包含水流量为0的数值，\n",
    "# 后一个表中，只含有水流量不为0的值，需要将两边进行连接，获知规约后的数据中的数据所属的事件数,利用处理后的数开始进行数据构造工作\n",
    "x.head()#18840\n",
    "x.to_excel('data_for_attr_const.xlsx')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>发生时间</th>\n",
       "      <th>开关机状态</th>\n",
       "      <th>加热中</th>\n",
       "      <th>保温中</th>\n",
       "      <th>实际温度</th>\n",
       "      <th>热水量</th>\n",
       "      <th>水流量</th>\n",
       "      <th>加热剩余时间</th>\n",
       "      <th>当前设置温度</th>\n",
       "      <th>事件编号</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2014-10-19 07:01:56</td>\n",
       "      <td>关</td>\n",
       "      <td>关</td>\n",
       "      <td>关</td>\n",
       "      <td>30°C</td>\n",
       "      <td>0%</td>\n",
       "      <td>8.0</td>\n",
       "      <td>0分钟</td>\n",
       "      <td>50°C</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>2014-10-19 07:38:16</td>\n",
       "      <td>关</td>\n",
       "      <td>关</td>\n",
       "      <td>关</td>\n",
       "      <td>30°C</td>\n",
       "      <td>0%</td>\n",
       "      <td>8.0</td>\n",
       "      <td>0分钟</td>\n",
       "      <td>50°C</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>381</th>\n",
       "      <td>2014-10-19 09:46:38</td>\n",
       "      <td>关</td>\n",
       "      <td>关</td>\n",
       "      <td>关</td>\n",
       "      <td>29°C</td>\n",
       "      <td>0%</td>\n",
       "      <td>16.0</td>\n",
       "      <td>0分钟</td>\n",
       "      <td>50°C</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>382</th>\n",
       "      <td>2014-10-19 09:46:40</td>\n",
       "      <td>关</td>\n",
       "      <td>关</td>\n",
       "      <td>关</td>\n",
       "      <td>29°C</td>\n",
       "      <td>0%</td>\n",
       "      <td>13.0</td>\n",
       "      <td>0分钟</td>\n",
       "      <td>50°C</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>383</th>\n",
       "      <td>2014-10-19 09:46:58</td>\n",
       "      <td>关</td>\n",
       "      <td>关</td>\n",
       "      <td>关</td>\n",
       "      <td>29°C</td>\n",
       "      <td>0%</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0分钟</td>\n",
       "      <td>50°C</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   发生时间 开关机状态 加热中 保温中  实际温度 热水量   水流量 加热剩余时间 当前设置温度  事件编号\n",
       "2   2014-10-19 07:01:56     关   关   关  30°C  0%   8.0    0分钟   50°C   1.0\n",
       "56  2014-10-19 07:38:16     关   关   关  30°C  0%   8.0    0分钟   50°C   2.0\n",
       "381 2014-10-19 09:46:38     关   关   关  29°C  0%  16.0    0分钟   50°C   3.0\n",
       "382 2014-10-19 09:46:40     关   关   关  29°C  0%  13.0    0分钟   50°C   3.0\n",
       "383 2014-10-19 09:46:58     关   关   关  29°C  0%   0.0    0分钟   50°C   3.0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_excel('data_for_attr_const.xlsx')\n",
    "# 将数据划分成一次用水事件！（*****）\n",
    "#-----第*1*步-----做基本处理，获取用于构造属性的数据表\n",
    "# 将数据划分成一次用水事件！（*****）\n",
    "# 思路：获取每个事件的序号值所在的最小的index值和最大的index值，然后将其连接，\n",
    "# 即： 去掉不同事件间的“事件编号”为空的值，保留同一个事件内的“事件编号”为空的值\n",
    "l=list(df[u'事件编号'])\n",
    "Adf = DataFrame([], columns = df.columns)# 创建一个空列表\n",
    "pos=-1\n",
    "MX = int(df[u'事件编号'].max())\n",
    "for j in range(MX):\n",
    "    y = []\n",
    "    for i in range(l.count(j+1)):\n",
    "        pos=l.index(j+1,pos+1)\n",
    "        y.append(pos)\n",
    "    a = min(y)\n",
    "    b = max(y)\n",
    "    temp = df.iloc[a:b+1,:]\n",
    "    Adf = pd.concat([Adf,temp])\n",
    "Adf[u'事件编号'].fillna(method='ffill',inplace = True) # 向后填充，填上了事件编号的空值\n",
    "Adf[[u'水流量']] = Adf[[u'水流量']].astype('float64')\n",
    "Adf.to_excel('1TimeWaterDivide.xlsx')\n",
    "Adf.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#-----第*2*步-----建立存放构造的属性的表\n",
    "df2 = pd.read_excel('1TimeWaterDivide.xlsx')\n",
    "df2['gap'] = df2[u'发生时间'].diff()\n",
    "MX = int(df2[u'事件编号'].max())# 获取当前事件数172\n",
    "fdf2 = DataFrame([], index = range(1,MX+1))# 创建一个空列表 用来存放属性规约结果\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Anaconda2\\lib\\site-packages\\ipykernel_launcher.py:64: DeprecationWarning: \n",
      ".ix is deprecated. Please use\n",
      ".loc for label based indexing or\n",
      ".iloc for positional indexing\n",
      "\n",
      "See the documentation here:\n",
      "http://pandas.pydata.org/pandas-docs/stable/indexing.html#deprecate_ix\n"
     ]
    }
   ],
   "source": [
    "#-----第*3*步-----开始构造属性\n",
    "#-----------------属性构造第一部分\n",
    "#构造属性第一部分：包含用水事件开始编号、用水事件结束编号、用水开始时间、用水结束时间、用水总时间、用水间隔时间、一次用水期间“水流量”为0的记录数\n",
    "fdf2.index.names = ['eventNUM']\n",
    "\n",
    "fdf2['stDataIndex'] = np.nan #用水事件开始编号\n",
    "fdf2['edDataIndex'] = np.nan #用水事件结束编号\n",
    "fdf2['stUseTime'] = np.nan #用水开始时间\n",
    "fdf2['enUseTime'] = np.nan #用水结束时间\n",
    "fdf2['AllUseTime'] = np.nan #用水总时间\n",
    "fdf2['gapTimes'] = np.nan #用水间隔时间\n",
    "fdf2['stopLines'] = np.nan # 一次用水期间“水流量”为0的记录数\n",
    "\n",
    "ds = pd.Timedelta(seconds = 2) # 发送阈值时间设置为2秒\n",
    "pos=-1# 标记变量     ******\n",
    "l=list(df2[u'事件编号'])\n",
    "\n",
    "# 以下空列表均是暂时存储数据\n",
    "stUI = []\n",
    "enUI = []\n",
    "startU = []\n",
    "endU = []\n",
    "allUT = []\n",
    "gapTS = []\n",
    "stopLines = []\n",
    "for j in range(MX):\n",
    "    # 计算事件编号j在列表中的最开始出现的index和最后出现的index\n",
    "    y = []# 存储时间编号j出现的所有的index（临时存储）\n",
    "    for i in range(l.count(j+1)):\n",
    "        pos=l.index(j+1,pos+1)\n",
    "        y.append(pos)\n",
    "    a = min(y)#出现值i最小的index\n",
    "    b = max(y)#出现值i最大的index\n",
    "    \n",
    "    #记录一次用水的开始事件编号、结束事件编号\n",
    "    stui= df2.index[a]\n",
    "    enui= df2.index[b]\n",
    "    stUI.append(stui)\n",
    "    enUI.append(enui)\n",
    "    \n",
    "    #记录一次用水开始时间、结束时间\n",
    "    stu = df2.iloc[a,0]-ds/2 # 设置用水开始时间=起始数据时间-发送阈值/2\n",
    "    enu = df2.iloc[b,0]+ds/2 # 设置结束用水时间=结束数据时间+发送阈值/2\n",
    "    startU.append(stu)\n",
    "    endU.append(enu)\n",
    "    \n",
    "    #记录一次用水总时长\n",
    "    allut = enu-stu\n",
    "    allUT.append(allut)\n",
    "    \n",
    "    #判断停顿的行数（一次事件中水流量为0的记录的条数）\n",
    "    stpts = df2.iloc[a:b+1,:]\n",
    "    f =list(stpts[u'水流量'])\n",
    "    stpt = f.count(0)#计算空值的个数\n",
    "    stopLines.append(stpt)\n",
    "  \n",
    "    n =0   \n",
    "    #判断停顿次数，中间有一个或多个空值均算作一次停顿\n",
    "    if a==b :\n",
    "        n=0\n",
    "    else:\n",
    "        tgap = df2.iloc[a:b+1,:]\n",
    "        for t in range(a,b):\n",
    "            g = tgap.ix[df2.index[t],[u'水流量']].values\n",
    "            g1 = tgap.ix[df2.index[t+1],[u'水流量']].values\n",
    "            if g1 == 0 and g!= 0:\n",
    "                n+=1\n",
    "    gapTS.append(n)\n",
    "    \n",
    "fdf2['stUseTime'] = startU\n",
    "fdf2['enUseTime'] = endU\n",
    "fdf2['stDataIndex'] = stUI\n",
    "fdf2['edDataIndex'] = enUI\n",
    "fdf2['AllUseTime'] = allUT\n",
    "fdf2['gapTimes'] =gapTS\n",
    "# 将一次用水事件的总时间转成以秒计\n",
    "fdf2['AllUseTime(s)']= fdf2['AllUseTime']/np.timedelta64(1, 's')\n",
    "fdf2['stopLines']= stopLines"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 构造属性第二部分：获取用水的时间点的小时数，即洗浴时间点\n",
    "fdf2['WashHour'] = np.nan\n",
    "\n",
    "for i in range(1,len(fdf2['stUseTime'])+1):\n",
    "    temp = fdf2.ix[i,'stUseTime'].strftime('%Y-%m-%d %H:%M:%S')# 将时间格式转成字符串,通过字符串截取获得时间点\n",
    "    c = temp[11:13]\n",
    "    d =int(c)\n",
    "    fdf2.ix[i,'WashHour'] = d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>stDataIndex</th>\n",
       "      <th>edDataIndex</th>\n",
       "      <th>stUseTime</th>\n",
       "      <th>enUseTime</th>\n",
       "      <th>AllUseTime</th>\n",
       "      <th>gapTimes</th>\n",
       "      <th>stopLines</th>\n",
       "      <th>AllUseTime(s)</th>\n",
       "      <th>WashHour</th>\n",
       "      <th>UseTime</th>\n",
       "      <th>GapTime</th>\n",
       "      <th>w_water</th>\n",
       "      <th>flow_volatility</th>\n",
       "      <th>water_rate</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>eventNUM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2014-10-19 07:01:55</td>\n",
       "      <td>2014-10-19 07:01:57</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>56</td>\n",
       "      <td>56</td>\n",
       "      <td>2014-10-19 07:38:15</td>\n",
       "      <td>2014-10-19 07:38:17</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>381</td>\n",
       "      <td>384</td>\n",
       "      <td>2014-10-19 09:46:37</td>\n",
       "      <td>2014-10-19 09:47:16</td>\n",
       "      <td>00:00:39</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>39.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>21.5</td>\n",
       "      <td>17.5</td>\n",
       "      <td>3.52</td>\n",
       "      <td>0.111174</td>\n",
       "      <td>16.372093</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>404</td>\n",
       "      <td>404</td>\n",
       "      <td>2014-10-19 11:50:16</td>\n",
       "      <td>2014-10-19 11:50:18</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.44</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>22.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>407</td>\n",
       "      <td>407</td>\n",
       "      <td>2014-10-19 13:56:20</td>\n",
       "      <td>2014-10-19 13:56:22</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          stDataIndex  edDataIndex           stUseTime           enUseTime  \\\n",
       "eventNUM                                                                     \n",
       "1                   2            2 2014-10-19 07:01:55 2014-10-19 07:01:57   \n",
       "2                  56           56 2014-10-19 07:38:15 2014-10-19 07:38:17   \n",
       "3                 381          384 2014-10-19 09:46:37 2014-10-19 09:47:16   \n",
       "4                 404          404 2014-10-19 11:50:16 2014-10-19 11:50:18   \n",
       "5                 407          407 2014-10-19 13:56:20 2014-10-19 13:56:22   \n",
       "\n",
       "         AllUseTime  gapTimes  stopLines  AllUseTime(s)  WashHour  UseTime  \\\n",
       "eventNUM                                                                     \n",
       "1          00:00:02         0          0            2.0       7.0      2.0   \n",
       "2          00:00:02         0          0            2.0       7.0      2.0   \n",
       "3          00:00:39         1          1           39.0       9.0     21.5   \n",
       "4          00:00:02         0          0            2.0      11.0      2.0   \n",
       "5          00:00:02         0          0            2.0      13.0      2.0   \n",
       "\n",
       "          GapTime  w_water  flow_volatility  water_rate  \n",
       "eventNUM                                                 \n",
       "1             0.0     0.16         0.000000    8.000000  \n",
       "2             0.0     0.16         0.000000    8.000000  \n",
       "3            17.5     3.52         0.111174   16.372093  \n",
       "4             0.0     0.44         0.000000   22.000000  \n",
       "5             0.0     0.16         0.000000    8.000000  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 构造属性第三部分：确定一次用水时间和停顿时间、总用水量、水流量波动、平均用户水量\n",
    "fdf2['UseTime'] = np.nan # 用水时间\n",
    "fdf2['GapTime'] = np.nan # 停顿时间\n",
    "fdf2['w_water'] = np.nan # 总用水量\n",
    "fdf2['flow_volatility'] = np.nan # 水流量波动\n",
    "fdf2['water_rate'] = np.nan #平均用水量\n",
    "\n",
    "\n",
    "# 计算停顿时间（具体所有方法见time_gap_compute.py，此处采用的是第二种方法)\n",
    "def gap_time_2(y):\n",
    "    gap_time_2 = pd.Timedelta(seconds = 0)\n",
    "    templist = []\n",
    "    allgap = 0\n",
    "    # 获取一次用水时间中间隔的行编号\n",
    "    for i in range(len(y)):\n",
    "        if y.iloc[i,6] == 0:\n",
    "            templist.append(i)\n",
    "    # 计算停顿时间    \n",
    "    if (len(y) ==1) | (templist==[]):# 如果该事件只有一个或者两个非零用水记录，直接让用水停顿时间等于0\n",
    "        gap_time_2 = gap_time_2\n",
    "    else:\n",
    "        for j in templist:# 采用书上公式：每条用水数据时长的和=（和上条数据的间隔时间/2+和下条数据的间隔时间/2）的和\n",
    "            gap_time_2 = gap_time_2 + y.iloc[j,-1]/2 + y.iloc[j+1,-1]/2\n",
    "    gap_time = gap_time_2/np.timedelta64(1,'s')\n",
    "    \n",
    "\n",
    "    return gap_time\n",
    "\n",
    "# 计算用水时间 和 总用水量\n",
    "def use_time(y):\n",
    "    send_time = pd.Timedelta(seconds = 2) # 定义信息发送延迟时间为2秒\n",
    "    use_time = pd.Timedelta(seconds = 0)\n",
    "    templist = []\n",
    "    w_water = 0 # 记录总用水量\n",
    "    # 获取一次用水时间用水的行编号\n",
    "    LASTIME = []#记录每个用水记录的持续用水时间\n",
    "    for i in range(len(y)):# 将所有用水量不为0的记录的行号进行记录\n",
    "        if y.iloc[i,6] != 0:\n",
    "            templist.append(i)\n",
    "    if len(y) ==1:# 如果用水量不为0的仅为1条，则用水时间为发送时间，用水持续时间为发送时间\n",
    "        use_time = send_time\n",
    "        lastime = send_time\n",
    "        w_water = lastime/np.timedelta64(1,'s')* y.iloc[0,6]# 该次用水量为用水持续时间*水流量\n",
    "        LASTIME.append(lastime/np.timedelta64(1,'s'))\n",
    "    else:\n",
    "        lastime = pd.Timedelta(seconds = 0)#用水时间=每条用水数据时长的和=（和上条数据的时间间隔/2+和下条数据的时间间隔/2）的和\n",
    "        for j in templist:\n",
    "            if j == 0:# 每一个用水事件开始时刻的用水持续时间=和下条数据的时间间隔/2+发送时间/2\n",
    "                lastime = y.iloc[j+1,-1]/2 + send_time/2\n",
    "            elif j == (len(y)-1):#每一个用水事件最后时刻的用水持续时间=和上条数据的时间间隔/2+发送时间/2\n",
    "                lastime = y.iloc[j,-1]/2 + send_time/2\n",
    "            else:\n",
    "                lastime = y.iloc[j,-1]/2 + y.iloc[j+1,-1]/2\n",
    "            use_time = use_time + lastime\n",
    "            w_water = w_water + lastime/np.timedelta64(1,'s')* y.iloc[j,6]\n",
    "            LASTIME.append(lastime/np.timedelta64(1,'s'))\n",
    "      \n",
    "    usetime = use_time/np.timedelta64(1,'s')\n",
    "    avg = w_water/usetime# 平均水流量=总用水量/总用水时间\n",
    "    \n",
    "    allwater = 0 # 计算水流量波动 = sum((单次水流的值-平均水流量)**2*持续时间)/总用水时间\n",
    "    if len(y) ==1:\n",
    "        allwater = (y.iloc[0,6]-avg)**2\n",
    "    else:\n",
    "        for i in range(len(templist)):\n",
    "            allwater = allwater + LASTIME[i]*(y.iloc[templist[i],6]-avg)**2 \n",
    "    flow_vola = allwater/100/usetime# 水流量波动 # 此处除以100为了让数字看起来正常点，符合原作者给出的配书中给的数据值\n",
    "        \n",
    "    return usetime, w_water/100, avg, flow_vola\n",
    "\n",
    "\n",
    "useTIME = []# 用水时间\n",
    "gapTIME = []# 间隔时间\n",
    "w_wat = []# 总用水量\n",
    "flow_volatility = []# 水流量波动\n",
    "avg_water_rate = [] # 平均水流量\n",
    "for n in range(1,int(MX+1)):\n",
    "    gp= gap_time_2(df2[df2[u'事件编号'] == n])\n",
    "    use,w_water,avg,flow_vola = use_time(df2[df2[u'事件编号'] == n])\n",
    "    gapTIME.append(gp)\n",
    "    useTIME.append(use)\n",
    "    w_wat.append(w_water)\n",
    "    flow_volatility.append(flow_vola)\n",
    "    avg_water_rate.append(avg)\n",
    "    \n",
    "fdf2['GapTime'] = gapTIME  \n",
    "fdf2['UseTime'] = useTIME # fdf2['AllUseTime(s)']- fdf2['GapTime']\n",
    "fdf2['w_water'] = w_wat\n",
    "fdf2['water_rate'] = avg_water_rate\n",
    "fdf2['flow_volatility'] = flow_volatility \n",
    "\n",
    "fdf2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Anaconda2\\lib\\site-packages\\ipykernel_launcher.py:50: RuntimeWarning: invalid value encountered in double_scalars\n",
      "D:\\Anaconda2\\lib\\site-packages\\ipykernel_launcher.py:23: DeprecationWarning: \n",
      ".ix is deprecated. Please use\n",
      ".loc for label based indexing or\n",
      ".iloc for positional indexing\n",
      "\n",
      "See the documentation here:\n",
      "http://pandas.pydata.org/pandas-docs/stable/indexing.html#deprecate_ix\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>stDataIndex</th>\n",
       "      <th>edDataIndex</th>\n",
       "      <th>stUseTime</th>\n",
       "      <th>enUseTime</th>\n",
       "      <th>AllUseTime</th>\n",
       "      <th>gapTimes</th>\n",
       "      <th>stopLines</th>\n",
       "      <th>AllUseTime(s)</th>\n",
       "      <th>WashHour</th>\n",
       "      <th>UseTime</th>\n",
       "      <th>GapTime</th>\n",
       "      <th>w_water</th>\n",
       "      <th>flow_volatility</th>\n",
       "      <th>water_rate</th>\n",
       "      <th>pause_volatility</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>eventNUM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2014-10-19 07:01:55</td>\n",
       "      <td>2014-10-19 07:01:57</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>56</td>\n",
       "      <td>56</td>\n",
       "      <td>2014-10-19 07:38:15</td>\n",
       "      <td>2014-10-19 07:38:17</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>381</td>\n",
       "      <td>384</td>\n",
       "      <td>2014-10-19 09:46:37</td>\n",
       "      <td>2014-10-19 09:47:16</td>\n",
       "      <td>00:00:39</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>39.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>21.5</td>\n",
       "      <td>17.5</td>\n",
       "      <td>3.52</td>\n",
       "      <td>0.111174</td>\n",
       "      <td>16.372093</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>404</td>\n",
       "      <td>404</td>\n",
       "      <td>2014-10-19 11:50:16</td>\n",
       "      <td>2014-10-19 11:50:18</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.44</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>22.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>407</td>\n",
       "      <td>407</td>\n",
       "      <td>2014-10-19 13:56:20</td>\n",
       "      <td>2014-10-19 13:56:22</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          stDataIndex  edDataIndex           stUseTime           enUseTime  \\\n",
       "eventNUM                                                                     \n",
       "1                   2            2 2014-10-19 07:01:55 2014-10-19 07:01:57   \n",
       "2                  56           56 2014-10-19 07:38:15 2014-10-19 07:38:17   \n",
       "3                 381          384 2014-10-19 09:46:37 2014-10-19 09:47:16   \n",
       "4                 404          404 2014-10-19 11:50:16 2014-10-19 11:50:18   \n",
       "5                 407          407 2014-10-19 13:56:20 2014-10-19 13:56:22   \n",
       "\n",
       "         AllUseTime  gapTimes  stopLines  AllUseTime(s)  WashHour  UseTime  \\\n",
       "eventNUM                                                                     \n",
       "1          00:00:02         0          0            2.0       7.0      2.0   \n",
       "2          00:00:02         0          0            2.0       7.0      2.0   \n",
       "3          00:00:39         1          1           39.0       9.0     21.5   \n",
       "4          00:00:02         0          0            2.0      11.0      2.0   \n",
       "5          00:00:02         0          0            2.0      13.0      2.0   \n",
       "\n",
       "          GapTime  w_water  flow_volatility  water_rate  pause_volatility  \n",
       "eventNUM                                                                   \n",
       "1             0.0     0.16         0.000000    8.000000               NaN  \n",
       "2             0.0     0.16         0.000000    8.000000               NaN  \n",
       "3            17.5     3.52         0.111174   16.372093               0.0  \n",
       "4             0.0     0.44         0.000000   22.000000               NaN  \n",
       "5             0.0     0.16         0.000000    8.000000               NaN  "
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 构造属性第四部分：计算停顿时长波动\n",
    "fdf2['pause_volatility'] = np.nan\n",
    "pause_volatility = [] # 停顿时长波动\n",
    "# 获取事件编号为eventnum的停顿次数\n",
    "def get_gaptimes(eventnum):\n",
    "    return fdf2['gapTimes'][eventnum] \n",
    "\n",
    "# 计算得出停顿时间和停顿时长波动（具体所有方法见time_gap_compute.py，此处采用的是第一种方法），因为这样可以算出单次停顿的具体时间\n",
    "# 停顿时长波动=sum((单次停顿时长-平均停顿时长)**2*持续时间)/总停顿时间\n",
    "def gap_time(x,gapTimes):\n",
    "    gap_time = pd.Timedelta(seconds = 0)\n",
    "    GAPTIME = []\n",
    "    pause_vola = 0\n",
    "    if len(x) ==1:\n",
    "        gap_time = gap_time\n",
    "        pause_vola = 0\n",
    "    else:\n",
    "        i=0\n",
    "        tempdf = DataFrame([])\n",
    "        while i< len(x)-1:\n",
    "            i= i+1\n",
    "            if (x.loc[x.index[i],u'水流量']) == 0:#若第i条水量为0\n",
    "                tempdf = tempdf.append(x.ix[x.index[i],:])# 存储所有水流量为0的数据的记录\n",
    "                if (x.loc[x.index[i+1],u'水流量']) != 0:# 若第i+1条水量不为0，说明这是一次停顿的结束\n",
    "                    start = tempdf.loc[tempdf.index[0],u'发生时间']    # 计算该次停顿的开始时刻\n",
    "                    end = tempdf.loc[tempdf.index[-1],u'发生时间']     # 计算该次停顿的结束时刻\n",
    "                    b = list(x.index).index(tempdf.index[0])-1# 获取该次停顿发生的前一个用水量非0的记录的index\n",
    "                    start_gap = x.iloc[b,0]\n",
    "                    c = list(x.index).index(tempdf.index[-1])+1# 获取该次停顿结束的后一个用水量非0的记录的index\n",
    "                    end_gap = x.iloc[c,0]\n",
    "#                     print start_gap,start,end,end_gap\n",
    "                    tempdf = DataFrame([]) # 清空tempdf，以记录下一次停顿时间\n",
    "                    t1 = (start-start_gap)/2 # 停顿开始时与上一条非零数据的时间间隔/2\n",
    "                    t2 = (end_gap-end)/2# 停顿结束时与下一条非零数据的时间间隔/2\n",
    "                    t3 = end-start # 中间停顿时间\n",
    "                    t = t1+t2+t3\n",
    "#                     print t1,t2,t3,t\n",
    "                    gap_time = gap_time+t\n",
    "                    GAPTIME.append(t/np.timedelta64(1,'s'))#将每一小段的停顿时间存入，以计算停顿时长波动\n",
    "    gap_time = gap_time/np.timedelta64(1,'s') # 将停顿时间转成“秒”\n",
    "    # 计算平均停顿时间 = 总停顿时间/停顿次数\n",
    "    if gapTimes != 0:# 若停顿次数不为0\n",
    "        avg = gap_time/gapTimes \n",
    "    else:# 若停顿次数为0，则平均停顿时间等于停顿的时间\n",
    "        avg = gap_time\n",
    "    \n",
    "    Allgap=0# 所有的停顿时间\n",
    "    for i in range(len(GAPTIME)):\n",
    "        Allgap = Allgap + GAPTIME[i]*(GAPTIME[i]-avg)**2\n",
    "    pause_vola = Allgap/gap_time# 水流量波动\n",
    "    return gap_time, pause_vola\n",
    "\n",
    "for n in range(1,MX+1):\n",
    "    gp, pause_vola = gap_time(df2[df2[u'事件编号'] == n], get_gaptimes(n))   \n",
    "    pause_volatility.append(pause_vola)\n",
    "\n",
    "fdf2['pause_volatility'] = pause_volatility \n",
    "fdf2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>stDataIndex</th>\n",
       "      <th>edDataIndex</th>\n",
       "      <th>stUseTime</th>\n",
       "      <th>enUseTime</th>\n",
       "      <th>AllUseTime</th>\n",
       "      <th>gapTimes</th>\n",
       "      <th>stopLines</th>\n",
       "      <th>AllUseTime(s)</th>\n",
       "      <th>WashHour</th>\n",
       "      <th>UseTime</th>\n",
       "      <th>GapTime</th>\n",
       "      <th>w_water</th>\n",
       "      <th>flow_volatility</th>\n",
       "      <th>water_rate</th>\n",
       "      <th>pause_volatility</th>\n",
       "      <th>use_water_rate</th>\n",
       "      <th>avg_pause_time</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>eventNUM</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2014-10-19 07:01:55</td>\n",
       "      <td>2014-10-19 07:01:57</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>56</td>\n",
       "      <td>56</td>\n",
       "      <td>2014-10-19 07:38:15</td>\n",
       "      <td>2014-10-19 07:38:17</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>381</td>\n",
       "      <td>384</td>\n",
       "      <td>2014-10-19 09:46:37</td>\n",
       "      <td>2014-10-19 09:47:16</td>\n",
       "      <td>00:00:39</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>39.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>21.5</td>\n",
       "      <td>17.5</td>\n",
       "      <td>3.52</td>\n",
       "      <td>0.111174</td>\n",
       "      <td>16.372093</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.551282</td>\n",
       "      <td>17.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>404</td>\n",
       "      <td>404</td>\n",
       "      <td>2014-10-19 11:50:16</td>\n",
       "      <td>2014-10-19 11:50:18</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.44</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>22.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>407</td>\n",
       "      <td>407</td>\n",
       "      <td>2014-10-19 13:56:20</td>\n",
       "      <td>2014-10-19 13:56:22</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.16</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          stDataIndex  edDataIndex           stUseTime           enUseTime  \\\n",
       "eventNUM                                                                     \n",
       "1                   2            2 2014-10-19 07:01:55 2014-10-19 07:01:57   \n",
       "2                  56           56 2014-10-19 07:38:15 2014-10-19 07:38:17   \n",
       "3                 381          384 2014-10-19 09:46:37 2014-10-19 09:47:16   \n",
       "4                 404          404 2014-10-19 11:50:16 2014-10-19 11:50:18   \n",
       "5                 407          407 2014-10-19 13:56:20 2014-10-19 13:56:22   \n",
       "\n",
       "         AllUseTime  gapTimes  stopLines  AllUseTime(s)  WashHour  UseTime  \\\n",
       "eventNUM                                                                     \n",
       "1          00:00:02         0          0            2.0       7.0      2.0   \n",
       "2          00:00:02         0          0            2.0       7.0      2.0   \n",
       "3          00:00:39         1          1           39.0       9.0     21.5   \n",
       "4          00:00:02         0          0            2.0      11.0      2.0   \n",
       "5          00:00:02         0          0            2.0      13.0      2.0   \n",
       "\n",
       "          GapTime  w_water  flow_volatility  water_rate  pause_volatility  \\\n",
       "eventNUM                                                                    \n",
       "1             0.0     0.16         0.000000    8.000000               NaN   \n",
       "2             0.0     0.16         0.000000    8.000000               NaN   \n",
       "3            17.5     3.52         0.111174   16.372093               0.0   \n",
       "4             0.0     0.44         0.000000   22.000000               NaN   \n",
       "5             0.0     0.16         0.000000    8.000000               NaN   \n",
       "\n",
       "          use_water_rate  avg_pause_time  \n",
       "eventNUM                                  \n",
       "1               1.000000             0.0  \n",
       "2               1.000000             0.0  \n",
       "3               0.551282            17.5  \n",
       "4               1.000000             0.0  \n",
       "5               1.000000             0.0  "
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 构造属性第五部分：一次用水事件中，用水时长的所占比重\n",
    "fdf2['use_water_rate'] = fdf2['UseTime']/fdf2['AllUseTime(s)']\n",
    "# 平均停顿时间\n",
    "# fdf2['avg_pause_time'] = fdf2['GapTime']/fdf2['gapTimes']# 不能这样除，除数可能为0\n",
    "fdf2['avg_pause_time'] = np.nan\n",
    "for i in range(1,len(fdf2)+1):\n",
    "    if fdf2.ix[i,['gapTimes']].values[0] != 0:\n",
    "        fdf2.ix[i,['avg_pause_time']] = fdf2.ix[i,['GapTime']].values[0] / fdf2.ix[i,['gapTimes']].values[0]\n",
    "    else :\n",
    "        fdf2.ix[i,['avg_pause_time']] = 0\n",
    "\n",
    "fdf2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>起始数据编号</th>\n",
       "      <th>终止数据编号</th>\n",
       "      <th>开始时间</th>\n",
       "      <th>结束时间</th>\n",
       "      <th>总用水时长（w_time）</th>\n",
       "      <th>停顿次数（pause）</th>\n",
       "      <th>停顿行数</th>\n",
       "      <th>所有使用时间总用水时长（s）</th>\n",
       "      <th>洗浴时间点</th>\n",
       "      <th>用水时长（use_water_time）</th>\n",
       "      <th>总停顿时长（w_pause_time）</th>\n",
       "      <th>总用水量（w_water）</th>\n",
       "      <th>水流量波动（flow_volatility）</th>\n",
       "      <th>平均水流量（water_rate）</th>\n",
       "      <th>停顿时长波动（pause_volatility）</th>\n",
       "      <th>用水/总时长（use_water_rate）</th>\n",
       "      <th>平均停顿时长（avg_pause_time）</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>事件编号</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2014-10-19 07:01:55</td>\n",
       "      <td>2014-10-19 07:01:57</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>56</td>\n",
       "      <td>56</td>\n",
       "      <td>2014-10-19 07:38:15</td>\n",
       "      <td>2014-10-19 07:38:17</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>381</td>\n",
       "      <td>384</td>\n",
       "      <td>2014-10-19 09:46:37</td>\n",
       "      <td>2014-10-19 09:47:16</td>\n",
       "      <td>00:00:39</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>39.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>21.5</td>\n",
       "      <td>17.5</td>\n",
       "      <td>3.520</td>\n",
       "      <td>0.111174</td>\n",
       "      <td>16.372093</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.551282</td>\n",
       "      <td>17.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>404</td>\n",
       "      <td>404</td>\n",
       "      <td>2014-10-19 11:50:16</td>\n",
       "      <td>2014-10-19 11:50:18</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.440</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>22.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>407</td>\n",
       "      <td>407</td>\n",
       "      <td>2014-10-19 13:56:20</td>\n",
       "      <td>2014-10-19 13:56:22</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>410</td>\n",
       "      <td>593</td>\n",
       "      <td>2014-10-19 15:34:38</td>\n",
       "      <td>2014-10-19 15:48:47</td>\n",
       "      <td>00:14:09</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>849.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>835.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>337.900</td>\n",
       "      <td>0.637375</td>\n",
       "      <td>40.467066</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.983510</td>\n",
       "      <td>14.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>612</td>\n",
       "      <td>618</td>\n",
       "      <td>2014-10-19 15:55:14</td>\n",
       "      <td>2014-10-19 15:55:30</td>\n",
       "      <td>00:00:16</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>8.780</td>\n",
       "      <td>0.479844</td>\n",
       "      <td>54.875000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>659</td>\n",
       "      <td>765</td>\n",
       "      <td>2014-10-19 17:23:20</td>\n",
       "      <td>2014-10-19 17:34:37</td>\n",
       "      <td>00:11:17</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>677.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>506.0</td>\n",
       "      <td>171.0</td>\n",
       "      <td>150.620</td>\n",
       "      <td>1.788448</td>\n",
       "      <td>29.766798</td>\n",
       "      <td>2209.000000</td>\n",
       "      <td>0.747415</td>\n",
       "      <td>85.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>772</td>\n",
       "      <td>922</td>\n",
       "      <td>2014-10-19 17:46:20</td>\n",
       "      <td>2014-10-19 17:55:05</td>\n",
       "      <td>00:08:45</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>525.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>525.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>134.160</td>\n",
       "      <td>0.841975</td>\n",
       "      <td>25.554286</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1025</td>\n",
       "      <td>1134</td>\n",
       "      <td>2014-10-19 21:32:44</td>\n",
       "      <td>2014-10-19 21:42:02</td>\n",
       "      <td>00:09:18</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>558.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>486.0</td>\n",
       "      <td>72.0</td>\n",
       "      <td>178.660</td>\n",
       "      <td>0.300480</td>\n",
       "      <td>36.761317</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.870968</td>\n",
       "      <td>72.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1139</td>\n",
       "      <td>1139</td>\n",
       "      <td>2014-10-19 21:47:04</td>\n",
       "      <td>2014-10-19 21:47:06</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>1141</td>\n",
       "      <td>1143</td>\n",
       "      <td>2014-10-19 21:54:29</td>\n",
       "      <td>2014-10-19 21:54:39</td>\n",
       "      <td>00:00:10</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>10.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.480</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.600000</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>1258</td>\n",
       "      <td>1258</td>\n",
       "      <td>2014-10-20 06:59:32</td>\n",
       "      <td>2014-10-20 06:59:34</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>1345</td>\n",
       "      <td>1424</td>\n",
       "      <td>2014-10-20 07:22:53</td>\n",
       "      <td>2014-10-20 07:38:49</td>\n",
       "      <td>00:15:56</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>956.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>611.0</td>\n",
       "      <td>345.0</td>\n",
       "      <td>299.585</td>\n",
       "      <td>2.145137</td>\n",
       "      <td>49.031915</td>\n",
       "      <td>1160.436232</td>\n",
       "      <td>0.639121</td>\n",
       "      <td>38.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1444</td>\n",
       "      <td>1445</td>\n",
       "      <td>2014-10-20 13:33:53</td>\n",
       "      <td>2014-10-20 13:33:57</td>\n",
       "      <td>00:00:04</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.460</td>\n",
       "      <td>0.002500</td>\n",
       "      <td>11.500000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1450</td>\n",
       "      <td>1460</td>\n",
       "      <td>2014-10-20 19:03:40</td>\n",
       "      <td>2014-10-20 19:04:10</td>\n",
       "      <td>00:00:30</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>30.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>30.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>13.860</td>\n",
       "      <td>0.807600</td>\n",
       "      <td>46.200000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1481</td>\n",
       "      <td>1532</td>\n",
       "      <td>2014-10-20 19:13:44</td>\n",
       "      <td>2014-10-20 19:17:52</td>\n",
       "      <td>00:04:08</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>248.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>248.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>76.475</td>\n",
       "      <td>0.095157</td>\n",
       "      <td>30.836694</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>1571</td>\n",
       "      <td>1632</td>\n",
       "      <td>2014-10-20 19:47:58</td>\n",
       "      <td>2014-10-20 19:53:36</td>\n",
       "      <td>00:05:38</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>338.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>289.0</td>\n",
       "      <td>49.0</td>\n",
       "      <td>91.600</td>\n",
       "      <td>2.724505</td>\n",
       "      <td>31.695502</td>\n",
       "      <td>484.000000</td>\n",
       "      <td>0.855030</td>\n",
       "      <td>24.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>1641</td>\n",
       "      <td>1641</td>\n",
       "      <td>2014-10-20 20:18:10</td>\n",
       "      <td>2014-10-20 20:18:12</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1659</td>\n",
       "      <td>1760</td>\n",
       "      <td>2014-10-20 21:46:21</td>\n",
       "      <td>2014-10-20 21:55:12</td>\n",
       "      <td>00:08:51</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>531.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>444.0</td>\n",
       "      <td>87.0</td>\n",
       "      <td>144.345</td>\n",
       "      <td>0.471283</td>\n",
       "      <td>32.510135</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.836158</td>\n",
       "      <td>87.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1876</td>\n",
       "      <td>1876</td>\n",
       "      <td>2014-10-20 23:02:12</td>\n",
       "      <td>2014-10-20 23:02:14</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1879</td>\n",
       "      <td>1879</td>\n",
       "      <td>2014-10-21 06:43:36</td>\n",
       "      <td>2014-10-21 06:43:38</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>1881</td>\n",
       "      <td>1883</td>\n",
       "      <td>2014-10-21 07:49:06</td>\n",
       "      <td>2014-10-21 07:49:14</td>\n",
       "      <td>00:00:08</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.170</td>\n",
       "      <td>0.024844</td>\n",
       "      <td>14.625000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2068</td>\n",
       "      <td>2207</td>\n",
       "      <td>2014-10-21 16:04:17</td>\n",
       "      <td>2014-10-21 16:14:14</td>\n",
       "      <td>00:09:57</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>597.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>584.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>126.050</td>\n",
       "      <td>0.917241</td>\n",
       "      <td>21.583904</td>\n",
       "      <td>1.447115</td>\n",
       "      <td>0.978224</td>\n",
       "      <td>3.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2220</td>\n",
       "      <td>2381</td>\n",
       "      <td>2014-10-21 16:23:06</td>\n",
       "      <td>2014-10-21 16:41:12</td>\n",
       "      <td>00:18:06</td>\n",
       "      <td>3</td>\n",
       "      <td>10</td>\n",
       "      <td>1086.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>728.0</td>\n",
       "      <td>358.0</td>\n",
       "      <td>157.730</td>\n",
       "      <td>0.238872</td>\n",
       "      <td>21.666209</td>\n",
       "      <td>3558.857852</td>\n",
       "      <td>0.670350</td>\n",
       "      <td>119.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2385</td>\n",
       "      <td>2385</td>\n",
       "      <td>2014-10-21 17:37:53</td>\n",
       "      <td>2014-10-21 17:37:55</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2451</td>\n",
       "      <td>2451</td>\n",
       "      <td>2014-10-21 18:37:56</td>\n",
       "      <td>2014-10-21 18:37:58</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2454</td>\n",
       "      <td>2528</td>\n",
       "      <td>2014-10-21 18:49:41</td>\n",
       "      <td>2014-10-21 18:56:24</td>\n",
       "      <td>00:06:43</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>403.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>365.0</td>\n",
       "      <td>38.0</td>\n",
       "      <td>95.700</td>\n",
       "      <td>2.029739</td>\n",
       "      <td>26.219178</td>\n",
       "      <td>144.000000</td>\n",
       "      <td>0.905707</td>\n",
       "      <td>19.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2533</td>\n",
       "      <td>2533</td>\n",
       "      <td>2014-10-21 19:01:42</td>\n",
       "      <td>2014-10-21 19:01:44</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2546</td>\n",
       "      <td>2615</td>\n",
       "      <td>2014-10-21 19:50:01</td>\n",
       "      <td>2014-10-21 19:55:12</td>\n",
       "      <td>00:05:11</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>311.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>311.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>91.620</td>\n",
       "      <td>0.354606</td>\n",
       "      <td>29.459807</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143</th>\n",
       "      <td>16061</td>\n",
       "      <td>16162</td>\n",
       "      <td>2014-11-07 20:44:22</td>\n",
       "      <td>2014-11-07 20:54:54</td>\n",
       "      <td>00:10:32</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>632.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>522.0</td>\n",
       "      <td>110.0</td>\n",
       "      <td>131.930</td>\n",
       "      <td>1.055207</td>\n",
       "      <td>25.273946</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.825949</td>\n",
       "      <td>110.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>144</th>\n",
       "      <td>16165</td>\n",
       "      <td>16171</td>\n",
       "      <td>2014-11-07 21:00:54</td>\n",
       "      <td>2014-11-07 21:01:22</td>\n",
       "      <td>00:00:28</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>28.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>28.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11.120</td>\n",
       "      <td>1.392755</td>\n",
       "      <td>39.714286</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>16186</td>\n",
       "      <td>16235</td>\n",
       "      <td>2014-11-07 21:08:02</td>\n",
       "      <td>2014-11-07 21:18:08</td>\n",
       "      <td>00:10:06</td>\n",
       "      <td>7</td>\n",
       "      <td>13</td>\n",
       "      <td>606.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>291.0</td>\n",
       "      <td>315.0</td>\n",
       "      <td>117.565</td>\n",
       "      <td>2.546181</td>\n",
       "      <td>40.400344</td>\n",
       "      <td>4156.904762</td>\n",
       "      <td>0.480198</td>\n",
       "      <td>45.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>16237</td>\n",
       "      <td>16364</td>\n",
       "      <td>2014-11-07 21:47:02</td>\n",
       "      <td>2014-11-07 21:59:01</td>\n",
       "      <td>00:11:59</td>\n",
       "      <td>3</td>\n",
       "      <td>18</td>\n",
       "      <td>719.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>489.0</td>\n",
       "      <td>230.0</td>\n",
       "      <td>148.440</td>\n",
       "      <td>0.539756</td>\n",
       "      <td>30.355828</td>\n",
       "      <td>978.006039</td>\n",
       "      <td>0.680111</td>\n",
       "      <td>76.666667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>16532</td>\n",
       "      <td>16553</td>\n",
       "      <td>2014-11-08 08:01:05</td>\n",
       "      <td>2014-11-08 08:02:42</td>\n",
       "      <td>00:01:37</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>97.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>83.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>48.540</td>\n",
       "      <td>0.446834</td>\n",
       "      <td>58.481928</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.855670</td>\n",
       "      <td>14.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>16563</td>\n",
       "      <td>16563</td>\n",
       "      <td>2014-11-08 08:23:05</td>\n",
       "      <td>2014-11-08 08:23:07</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.200</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>16565</td>\n",
       "      <td>16581</td>\n",
       "      <td>2014-11-08 08:46:21</td>\n",
       "      <td>2014-11-08 08:49:17</td>\n",
       "      <td>00:02:56</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>176.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>112.5</td>\n",
       "      <td>63.5</td>\n",
       "      <td>34.590</td>\n",
       "      <td>4.465269</td>\n",
       "      <td>30.746667</td>\n",
       "      <td>473.062500</td>\n",
       "      <td>0.639205</td>\n",
       "      <td>31.750000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>150</th>\n",
       "      <td>16632</td>\n",
       "      <td>16632</td>\n",
       "      <td>2014-11-08 11:47:35</td>\n",
       "      <td>2014-11-08 11:47:37</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>151</th>\n",
       "      <td>16634</td>\n",
       "      <td>16634</td>\n",
       "      <td>2014-11-08 12:15:36</td>\n",
       "      <td>2014-11-08 12:15:38</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>152</th>\n",
       "      <td>16745</td>\n",
       "      <td>16745</td>\n",
       "      <td>2014-11-08 18:53:28</td>\n",
       "      <td>2014-11-08 18:53:30</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.200</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>153</th>\n",
       "      <td>16747</td>\n",
       "      <td>16752</td>\n",
       "      <td>2014-11-08 20:08:24</td>\n",
       "      <td>2014-11-08 20:08:40</td>\n",
       "      <td>00:00:16</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>16.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>5.720</td>\n",
       "      <td>0.825556</td>\n",
       "      <td>47.666667</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>154</th>\n",
       "      <td>16788</td>\n",
       "      <td>16900</td>\n",
       "      <td>2014-11-08 22:05:49</td>\n",
       "      <td>2014-11-08 22:14:03</td>\n",
       "      <td>00:08:14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>494.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>494.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>174.565</td>\n",
       "      <td>0.291971</td>\n",
       "      <td>35.337045</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>155</th>\n",
       "      <td>16951</td>\n",
       "      <td>17047</td>\n",
       "      <td>2014-11-08 22:36:26</td>\n",
       "      <td>2014-11-08 22:50:05</td>\n",
       "      <td>00:13:39</td>\n",
       "      <td>2</td>\n",
       "      <td>18</td>\n",
       "      <td>819.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>425.0</td>\n",
       "      <td>394.0</td>\n",
       "      <td>125.780</td>\n",
       "      <td>0.867586</td>\n",
       "      <td>29.595294</td>\n",
       "      <td>361.000000</td>\n",
       "      <td>0.518926</td>\n",
       "      <td>197.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>156</th>\n",
       "      <td>17212</td>\n",
       "      <td>17226</td>\n",
       "      <td>2014-11-09 07:38:03</td>\n",
       "      <td>2014-11-09 07:40:40</td>\n",
       "      <td>00:02:37</td>\n",
       "      <td>1</td>\n",
       "      <td>12</td>\n",
       "      <td>157.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>146.0</td>\n",
       "      <td>2.130</td>\n",
       "      <td>0.309587</td>\n",
       "      <td>19.363636</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.070064</td>\n",
       "      <td>146.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>157</th>\n",
       "      <td>17276</td>\n",
       "      <td>17276</td>\n",
       "      <td>2014-11-09 07:51:59</td>\n",
       "      <td>2014-11-09 07:52:01</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>158</th>\n",
       "      <td>17507</td>\n",
       "      <td>17539</td>\n",
       "      <td>2014-11-09 21:06:23</td>\n",
       "      <td>2014-11-09 21:08:23</td>\n",
       "      <td>00:02:00</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>120.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>120.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>73.900</td>\n",
       "      <td>0.116014</td>\n",
       "      <td>61.583333</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>159</th>\n",
       "      <td>17764</td>\n",
       "      <td>17764</td>\n",
       "      <td>2014-11-10 07:04:35</td>\n",
       "      <td>2014-11-10 07:04:37</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>160</th>\n",
       "      <td>17766</td>\n",
       "      <td>17767</td>\n",
       "      <td>2014-11-10 09:09:18</td>\n",
       "      <td>2014-11-10 09:09:22</td>\n",
       "      <td>00:00:04</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.020</td>\n",
       "      <td>0.002500</td>\n",
       "      <td>25.500000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>161</th>\n",
       "      <td>17795</td>\n",
       "      <td>17796</td>\n",
       "      <td>2014-11-10 11:01:56</td>\n",
       "      <td>2014-11-10 11:02:00</td>\n",
       "      <td>00:00:04</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.720</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>18.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>162</th>\n",
       "      <td>17843</td>\n",
       "      <td>17846</td>\n",
       "      <td>2014-11-10 12:37:10</td>\n",
       "      <td>2014-11-10 12:37:26</td>\n",
       "      <td>00:00:16</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>16.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2.200</td>\n",
       "      <td>0.021818</td>\n",
       "      <td>20.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.687500</td>\n",
       "      <td>5.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>163</th>\n",
       "      <td>17896</td>\n",
       "      <td>17896</td>\n",
       "      <td>2014-11-10 13:08:40</td>\n",
       "      <td>2014-11-10 13:08:42</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>164</th>\n",
       "      <td>17997</td>\n",
       "      <td>18141</td>\n",
       "      <td>2014-11-10 15:49:11</td>\n",
       "      <td>2014-11-10 16:01:14</td>\n",
       "      <td>00:12:03</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>723.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>723.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>197.015</td>\n",
       "      <td>0.397724</td>\n",
       "      <td>27.249654</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>165</th>\n",
       "      <td>18198</td>\n",
       "      <td>18324</td>\n",
       "      <td>2014-11-10 16:25:26</td>\n",
       "      <td>2014-11-10 16:36:12</td>\n",
       "      <td>00:10:46</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>646.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>570.0</td>\n",
       "      <td>76.0</td>\n",
       "      <td>183.835</td>\n",
       "      <td>0.542270</td>\n",
       "      <td>32.251754</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.882353</td>\n",
       "      <td>76.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>166</th>\n",
       "      <td>18371</td>\n",
       "      <td>18371</td>\n",
       "      <td>2014-11-10 18:00:33</td>\n",
       "      <td>2014-11-10 18:00:35</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>167</th>\n",
       "      <td>18405</td>\n",
       "      <td>18452</td>\n",
       "      <td>2014-11-10 18:52:18</td>\n",
       "      <td>2014-11-10 19:03:17</td>\n",
       "      <td>00:10:59</td>\n",
       "      <td>5</td>\n",
       "      <td>10</td>\n",
       "      <td>659.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>244.0</td>\n",
       "      <td>415.0</td>\n",
       "      <td>80.155</td>\n",
       "      <td>5.045207</td>\n",
       "      <td>32.850410</td>\n",
       "      <td>6703.421687</td>\n",
       "      <td>0.370258</td>\n",
       "      <td>83.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>168</th>\n",
       "      <td>18465</td>\n",
       "      <td>18470</td>\n",
       "      <td>2014-11-10 19:12:32</td>\n",
       "      <td>2014-11-10 19:12:52</td>\n",
       "      <td>00:00:20</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>20.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.545</td>\n",
       "      <td>2.586994</td>\n",
       "      <td>47.725000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>169</th>\n",
       "      <td>18534</td>\n",
       "      <td>18652</td>\n",
       "      <td>2014-11-10 21:38:28</td>\n",
       "      <td>2014-11-10 21:51:09</td>\n",
       "      <td>00:12:41</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "      <td>761.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>536.5</td>\n",
       "      <td>224.5</td>\n",
       "      <td>160.190</td>\n",
       "      <td>0.585559</td>\n",
       "      <td>29.858341</td>\n",
       "      <td>1242.562500</td>\n",
       "      <td>0.704993</td>\n",
       "      <td>112.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>170</th>\n",
       "      <td>18669</td>\n",
       "      <td>18744</td>\n",
       "      <td>2014-11-10 21:55:28</td>\n",
       "      <td>2014-11-10 22:00:47</td>\n",
       "      <td>00:05:19</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>319.0</td>\n",
       "      <td>21.0</td>\n",
       "      <td>319.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>79.155</td>\n",
       "      <td>0.051078</td>\n",
       "      <td>24.813480</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>171</th>\n",
       "      <td>18798</td>\n",
       "      <td>18798</td>\n",
       "      <td>2014-11-10 22:19:42</td>\n",
       "      <td>2014-11-10 22:19:44</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>172</th>\n",
       "      <td>18800</td>\n",
       "      <td>18800</td>\n",
       "      <td>2014-11-10 22:49:06</td>\n",
       "      <td>2014-11-10 22:49:08</td>\n",
       "      <td>00:00:02</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.160</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>8.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>172 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      起始数据编号  终止数据编号                开始时间                结束时间 总用水时长（w_time）  \\\n",
       "事件编号                                                                         \n",
       "1          2       2 2014-10-19 07:01:55 2014-10-19 07:01:57      00:00:02   \n",
       "2         56      56 2014-10-19 07:38:15 2014-10-19 07:38:17      00:00:02   \n",
       "3        381     384 2014-10-19 09:46:37 2014-10-19 09:47:16      00:00:39   \n",
       "4        404     404 2014-10-19 11:50:16 2014-10-19 11:50:18      00:00:02   \n",
       "5        407     407 2014-10-19 13:56:20 2014-10-19 13:56:22      00:00:02   \n",
       "6        410     593 2014-10-19 15:34:38 2014-10-19 15:48:47      00:14:09   \n",
       "7        612     618 2014-10-19 15:55:14 2014-10-19 15:55:30      00:00:16   \n",
       "8        659     765 2014-10-19 17:23:20 2014-10-19 17:34:37      00:11:17   \n",
       "9        772     922 2014-10-19 17:46:20 2014-10-19 17:55:05      00:08:45   \n",
       "10      1025    1134 2014-10-19 21:32:44 2014-10-19 21:42:02      00:09:18   \n",
       "11      1139    1139 2014-10-19 21:47:04 2014-10-19 21:47:06      00:00:02   \n",
       "12      1141    1143 2014-10-19 21:54:29 2014-10-19 21:54:39      00:00:10   \n",
       "13      1258    1258 2014-10-20 06:59:32 2014-10-20 06:59:34      00:00:02   \n",
       "14      1345    1424 2014-10-20 07:22:53 2014-10-20 07:38:49      00:15:56   \n",
       "15      1444    1445 2014-10-20 13:33:53 2014-10-20 13:33:57      00:00:04   \n",
       "16      1450    1460 2014-10-20 19:03:40 2014-10-20 19:04:10      00:00:30   \n",
       "17      1481    1532 2014-10-20 19:13:44 2014-10-20 19:17:52      00:04:08   \n",
       "18      1571    1632 2014-10-20 19:47:58 2014-10-20 19:53:36      00:05:38   \n",
       "19      1641    1641 2014-10-20 20:18:10 2014-10-20 20:18:12      00:00:02   \n",
       "20      1659    1760 2014-10-20 21:46:21 2014-10-20 21:55:12      00:08:51   \n",
       "21      1876    1876 2014-10-20 23:02:12 2014-10-20 23:02:14      00:00:02   \n",
       "22      1879    1879 2014-10-21 06:43:36 2014-10-21 06:43:38      00:00:02   \n",
       "23      1881    1883 2014-10-21 07:49:06 2014-10-21 07:49:14      00:00:08   \n",
       "24      2068    2207 2014-10-21 16:04:17 2014-10-21 16:14:14      00:09:57   \n",
       "25      2220    2381 2014-10-21 16:23:06 2014-10-21 16:41:12      00:18:06   \n",
       "26      2385    2385 2014-10-21 17:37:53 2014-10-21 17:37:55      00:00:02   \n",
       "27      2451    2451 2014-10-21 18:37:56 2014-10-21 18:37:58      00:00:02   \n",
       "28      2454    2528 2014-10-21 18:49:41 2014-10-21 18:56:24      00:06:43   \n",
       "29      2533    2533 2014-10-21 19:01:42 2014-10-21 19:01:44      00:00:02   \n",
       "30      2546    2615 2014-10-21 19:50:01 2014-10-21 19:55:12      00:05:11   \n",
       "...      ...     ...                 ...                 ...           ...   \n",
       "143    16061   16162 2014-11-07 20:44:22 2014-11-07 20:54:54      00:10:32   \n",
       "144    16165   16171 2014-11-07 21:00:54 2014-11-07 21:01:22      00:00:28   \n",
       "145    16186   16235 2014-11-07 21:08:02 2014-11-07 21:18:08      00:10:06   \n",
       "146    16237   16364 2014-11-07 21:47:02 2014-11-07 21:59:01      00:11:59   \n",
       "147    16532   16553 2014-11-08 08:01:05 2014-11-08 08:02:42      00:01:37   \n",
       "148    16563   16563 2014-11-08 08:23:05 2014-11-08 08:23:07      00:00:02   \n",
       "149    16565   16581 2014-11-08 08:46:21 2014-11-08 08:49:17      00:02:56   \n",
       "150    16632   16632 2014-11-08 11:47:35 2014-11-08 11:47:37      00:00:02   \n",
       "151    16634   16634 2014-11-08 12:15:36 2014-11-08 12:15:38      00:00:02   \n",
       "152    16745   16745 2014-11-08 18:53:28 2014-11-08 18:53:30      00:00:02   \n",
       "153    16747   16752 2014-11-08 20:08:24 2014-11-08 20:08:40      00:00:16   \n",
       "154    16788   16900 2014-11-08 22:05:49 2014-11-08 22:14:03      00:08:14   \n",
       "155    16951   17047 2014-11-08 22:36:26 2014-11-08 22:50:05      00:13:39   \n",
       "156    17212   17226 2014-11-09 07:38:03 2014-11-09 07:40:40      00:02:37   \n",
       "157    17276   17276 2014-11-09 07:51:59 2014-11-09 07:52:01      00:00:02   \n",
       "158    17507   17539 2014-11-09 21:06:23 2014-11-09 21:08:23      00:02:00   \n",
       "159    17764   17764 2014-11-10 07:04:35 2014-11-10 07:04:37      00:00:02   \n",
       "160    17766   17767 2014-11-10 09:09:18 2014-11-10 09:09:22      00:00:04   \n",
       "161    17795   17796 2014-11-10 11:01:56 2014-11-10 11:02:00      00:00:04   \n",
       "162    17843   17846 2014-11-10 12:37:10 2014-11-10 12:37:26      00:00:16   \n",
       "163    17896   17896 2014-11-10 13:08:40 2014-11-10 13:08:42      00:00:02   \n",
       "164    17997   18141 2014-11-10 15:49:11 2014-11-10 16:01:14      00:12:03   \n",
       "165    18198   18324 2014-11-10 16:25:26 2014-11-10 16:36:12      00:10:46   \n",
       "166    18371   18371 2014-11-10 18:00:33 2014-11-10 18:00:35      00:00:02   \n",
       "167    18405   18452 2014-11-10 18:52:18 2014-11-10 19:03:17      00:10:59   \n",
       "168    18465   18470 2014-11-10 19:12:32 2014-11-10 19:12:52      00:00:20   \n",
       "169    18534   18652 2014-11-10 21:38:28 2014-11-10 21:51:09      00:12:41   \n",
       "170    18669   18744 2014-11-10 21:55:28 2014-11-10 22:00:47      00:05:19   \n",
       "171    18798   18798 2014-11-10 22:19:42 2014-11-10 22:19:44      00:00:02   \n",
       "172    18800   18800 2014-11-10 22:49:06 2014-11-10 22:49:08      00:00:02   \n",
       "\n",
       "      停顿次数（pause）  停顿行数  所有使用时间总用水时长（s）  洗浴时间点  用水时长（use_water_time）  \\\n",
       "事件编号                                                                   \n",
       "1               0     0             2.0    7.0                   2.0   \n",
       "2               0     0             2.0    7.0                   2.0   \n",
       "3               1     1            39.0    9.0                  21.5   \n",
       "4               0     0             2.0   11.0                   2.0   \n",
       "5               0     0             2.0   13.0                   2.0   \n",
       "6               1     2           849.0   15.0                 835.0   \n",
       "7               0     0            16.0   15.0                  16.0   \n",
       "8               2     3           677.0   17.0                 506.0   \n",
       "9               0     0           525.0   17.0                 525.0   \n",
       "10              1     2           558.0   21.0                 486.0   \n",
       "11              0     0             2.0   21.0                   2.0   \n",
       "12              1     1            10.0   21.0                   6.0   \n",
       "13              0     0             2.0    6.0                   2.0   \n",
       "14              9     9           956.0    7.0                 611.0   \n",
       "15              0     0             4.0   13.0                   4.0   \n",
       "16              0     0            30.0   19.0                  30.0   \n",
       "17              0     0           248.0   19.0                 248.0   \n",
       "18              2     2           338.0   19.0                 289.0   \n",
       "19              0     0             2.0   20.0                   2.0   \n",
       "20              1     2           531.0   21.0                 444.0   \n",
       "21              0     0             2.0   23.0                   2.0   \n",
       "22              0     0             2.0    6.0                   2.0   \n",
       "23              0     0             8.0    7.0                   8.0   \n",
       "24              4     4           597.0   16.0                 584.0   \n",
       "25              3    10          1086.0   16.0                 728.0   \n",
       "26              0     0             2.0   17.0                   2.0   \n",
       "27              0     0             2.0   18.0                   2.0   \n",
       "28              2     2           403.0   18.0                 365.0   \n",
       "29              0     0             2.0   19.0                   2.0   \n",
       "30              0     0           311.0   19.0                 311.0   \n",
       "...           ...   ...             ...    ...                   ...   \n",
       "143             1     1           632.0   20.0                 522.0   \n",
       "144             0     0            28.0   21.0                  28.0   \n",
       "145             7    13           606.0   21.0                 291.0   \n",
       "146             3    18           719.0   21.0                 489.0   \n",
       "147             1     1            97.0    8.0                  83.0   \n",
       "148             0     0             2.0    8.0                   2.0   \n",
       "149             2     2           176.0    8.0                 112.5   \n",
       "150             0     0             2.0   11.0                   2.0   \n",
       "151             0     0             2.0   12.0                   2.0   \n",
       "152             0     0             2.0   18.0                   2.0   \n",
       "153             1     1            16.0   20.0                  12.0   \n",
       "154             0     0           494.0   22.0                 494.0   \n",
       "155             2    18           819.0   22.0                 425.0   \n",
       "156             1    12           157.0    7.0                  11.0   \n",
       "157             0     0             2.0    7.0                   2.0   \n",
       "158             0     0           120.0   21.0                 120.0   \n",
       "159             0     0             2.0    7.0                   2.0   \n",
       "160             0     0             4.0    9.0                   4.0   \n",
       "161             0     0             4.0   11.0                   4.0   \n",
       "162             1     1            16.0   12.0                  11.0   \n",
       "163             0     0             2.0   13.0                   2.0   \n",
       "164             0     0           723.0   15.0                 723.0   \n",
       "165             1     3           646.0   16.0                 570.0   \n",
       "166             0     0             2.0   18.0                   2.0   \n",
       "167             5    10           659.0   18.0                 244.0   \n",
       "168             0     0            20.0   19.0                  20.0   \n",
       "169             2     6           761.0   21.0                 536.5   \n",
       "170             0     0           319.0   21.0                 319.0   \n",
       "171             0     0             2.0   22.0                   2.0   \n",
       "172             0     0             2.0   22.0                   2.0   \n",
       "\n",
       "      总停顿时长（w_pause_time）  总用水量（w_water）  水流量波动（flow_volatility）  \\\n",
       "事件编号                                                               \n",
       "1                     0.0          0.160                0.000000   \n",
       "2                     0.0          0.160                0.000000   \n",
       "3                    17.5          3.520                0.111174   \n",
       "4                     0.0          0.440                0.000000   \n",
       "5                     0.0          0.160                0.000000   \n",
       "6                    14.0        337.900                0.637375   \n",
       "7                     0.0          8.780                0.479844   \n",
       "8                   171.0        150.620                1.788448   \n",
       "9                     0.0        134.160                0.841975   \n",
       "10                   72.0        178.660                0.300480   \n",
       "11                    0.0          0.160                0.000000   \n",
       "12                    4.0          0.480                0.000000   \n",
       "13                    0.0          0.160                0.000000   \n",
       "14                  345.0        299.585                2.145137   \n",
       "15                    0.0          0.460                0.002500   \n",
       "16                    0.0         13.860                0.807600   \n",
       "17                    0.0         76.475                0.095157   \n",
       "18                   49.0         91.600                2.724505   \n",
       "19                    0.0          0.160                0.000000   \n",
       "20                   87.0        144.345                0.471283   \n",
       "21                    0.0          0.160                0.000000   \n",
       "22                    0.0          0.160                0.000000   \n",
       "23                    0.0          1.170                0.024844   \n",
       "24                   13.0        126.050                0.917241   \n",
       "25                  358.0        157.730                0.238872   \n",
       "26                    0.0          0.160                0.000000   \n",
       "27                    0.0          0.160                0.000000   \n",
       "28                   38.0         95.700                2.029739   \n",
       "29                    0.0          0.160                0.000000   \n",
       "30                    0.0         91.620                0.354606   \n",
       "...                   ...            ...                     ...   \n",
       "143                 110.0        131.930                1.055207   \n",
       "144                   0.0         11.120                1.392755   \n",
       "145                 315.0        117.565                2.546181   \n",
       "146                 230.0        148.440                0.539756   \n",
       "147                  14.0         48.540                0.446834   \n",
       "148                   0.0          0.200                0.000000   \n",
       "149                  63.5         34.590                4.465269   \n",
       "150                   0.0          0.160                0.000000   \n",
       "151                   0.0          0.160                0.000000   \n",
       "152                   0.0          0.200                0.000000   \n",
       "153                   4.0          5.720                0.825556   \n",
       "154                   0.0        174.565                0.291971   \n",
       "155                 394.0        125.780                0.867586   \n",
       "156                 146.0          2.130                0.309587   \n",
       "157                   0.0          0.160                0.000000   \n",
       "158                   0.0         73.900                0.116014   \n",
       "159                   0.0          0.160                0.000000   \n",
       "160                   0.0          1.020                0.002500   \n",
       "161                   0.0          0.720                0.000000   \n",
       "162                   5.0          2.200                0.021818   \n",
       "163                   0.0          0.160                0.000000   \n",
       "164                   0.0        197.015                0.397724   \n",
       "165                  76.0        183.835                0.542270   \n",
       "166                   0.0          0.160                0.000000   \n",
       "167                 415.0         80.155                5.045207   \n",
       "168                   0.0          9.545                2.586994   \n",
       "169                 224.5        160.190                0.585559   \n",
       "170                   0.0         79.155                0.051078   \n",
       "171                   0.0          0.160                0.000000   \n",
       "172                   0.0          0.160                0.000000   \n",
       "\n",
       "      平均水流量（water_rate）  停顿时长波动（pause_volatility）  用水/总时长（use_water_rate）  \\\n",
       "事件编号                                                                        \n",
       "1              8.000000                       NaN                1.000000   \n",
       "2              8.000000                       NaN                1.000000   \n",
       "3             16.372093                  0.000000                0.551282   \n",
       "4             22.000000                       NaN                1.000000   \n",
       "5              8.000000                       NaN                1.000000   \n",
       "6             40.467066                  0.000000                0.983510   \n",
       "7             54.875000                       NaN                1.000000   \n",
       "8             29.766798               2209.000000                0.747415   \n",
       "9             25.554286                       NaN                1.000000   \n",
       "10            36.761317                  0.000000                0.870968   \n",
       "11             8.000000                       NaN                1.000000   \n",
       "12             8.000000                  0.000000                0.600000   \n",
       "13             8.000000                       NaN                1.000000   \n",
       "14            49.031915               1160.436232                0.639121   \n",
       "15            11.500000                       NaN                1.000000   \n",
       "16            46.200000                       NaN                1.000000   \n",
       "17            30.836694                       NaN                1.000000   \n",
       "18            31.695502                484.000000                0.855030   \n",
       "19             8.000000                       NaN                1.000000   \n",
       "20            32.510135                  0.000000                0.836158   \n",
       "21             8.000000                       NaN                1.000000   \n",
       "22             8.000000                       NaN                1.000000   \n",
       "23            14.625000                       NaN                1.000000   \n",
       "24            21.583904                  1.447115                0.978224   \n",
       "25            21.666209               3558.857852                0.670350   \n",
       "26             8.000000                       NaN                1.000000   \n",
       "27             8.000000                       NaN                1.000000   \n",
       "28            26.219178                144.000000                0.905707   \n",
       "29             8.000000                       NaN                1.000000   \n",
       "30            29.459807                       NaN                1.000000   \n",
       "...                 ...                       ...                     ...   \n",
       "143           25.273946                  0.000000                0.825949   \n",
       "144           39.714286                       NaN                1.000000   \n",
       "145           40.400344               4156.904762                0.480198   \n",
       "146           30.355828                978.006039                0.680111   \n",
       "147           58.481928                  0.000000                0.855670   \n",
       "148           10.000000                       NaN                1.000000   \n",
       "149           30.746667                473.062500                0.639205   \n",
       "150            8.000000                       NaN                1.000000   \n",
       "151            8.000000                       NaN                1.000000   \n",
       "152           10.000000                       NaN                1.000000   \n",
       "153           47.666667                  0.000000                0.750000   \n",
       "154           35.337045                       NaN                1.000000   \n",
       "155           29.595294                361.000000                0.518926   \n",
       "156           19.363636                  0.000000                0.070064   \n",
       "157            8.000000                       NaN                1.000000   \n",
       "158           61.583333                       NaN                1.000000   \n",
       "159            8.000000                       NaN                1.000000   \n",
       "160           25.500000                       NaN                1.000000   \n",
       "161           18.000000                       NaN                1.000000   \n",
       "162           20.000000                  0.000000                0.687500   \n",
       "163            8.000000                       NaN                1.000000   \n",
       "164           27.249654                       NaN                1.000000   \n",
       "165           32.251754                  0.000000                0.882353   \n",
       "166            8.000000                       NaN                1.000000   \n",
       "167           32.850410               6703.421687                0.370258   \n",
       "168           47.725000                       NaN                1.000000   \n",
       "169           29.858341               1242.562500                0.704993   \n",
       "170           24.813480                       NaN                1.000000   \n",
       "171            8.000000                       NaN                1.000000   \n",
       "172            8.000000                       NaN                1.000000   \n",
       "\n",
       "      平均停顿时长（avg_pause_time）  \n",
       "事件编号                          \n",
       "1                   0.000000  \n",
       "2                   0.000000  \n",
       "3                  17.500000  \n",
       "4                   0.000000  \n",
       "5                   0.000000  \n",
       "6                  14.000000  \n",
       "7                   0.000000  \n",
       "8                  85.500000  \n",
       "9                   0.000000  \n",
       "10                 72.000000  \n",
       "11                  0.000000  \n",
       "12                  4.000000  \n",
       "13                  0.000000  \n",
       "14                 38.333333  \n",
       "15                  0.000000  \n",
       "16                  0.000000  \n",
       "17                  0.000000  \n",
       "18                 24.500000  \n",
       "19                  0.000000  \n",
       "20                 87.000000  \n",
       "21                  0.000000  \n",
       "22                  0.000000  \n",
       "23                  0.000000  \n",
       "24                  3.250000  \n",
       "25                119.333333  \n",
       "26                  0.000000  \n",
       "27                  0.000000  \n",
       "28                 19.000000  \n",
       "29                  0.000000  \n",
       "30                  0.000000  \n",
       "...                      ...  \n",
       "143               110.000000  \n",
       "144                 0.000000  \n",
       "145                45.000000  \n",
       "146                76.666667  \n",
       "147                14.000000  \n",
       "148                 0.000000  \n",
       "149                31.750000  \n",
       "150                 0.000000  \n",
       "151                 0.000000  \n",
       "152                 0.000000  \n",
       "153                 4.000000  \n",
       "154                 0.000000  \n",
       "155               197.000000  \n",
       "156               146.000000  \n",
       "157                 0.000000  \n",
       "158                 0.000000  \n",
       "159                 0.000000  \n",
       "160                 0.000000  \n",
       "161                 0.000000  \n",
       "162                 5.000000  \n",
       "163                 0.000000  \n",
       "164                 0.000000  \n",
       "165                76.000000  \n",
       "166                 0.000000  \n",
       "167                83.000000  \n",
       "168                 0.000000  \n",
       "169               112.250000  \n",
       "170                 0.000000  \n",
       "171                 0.000000  \n",
       "172                 0.000000  \n",
       "\n",
       "[172 rows x 17 columns]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 属性构造结束，将各列重命名，然后保存\n",
    "fdf2.rename(columns={'stDataIndex':u'起始数据编号','edDataIndex':u'终止数据编号','stUseTime':u'开始时间','enUseTime':u'结束时间',\\\n",
    "                  'AllUseTime':u'总用水时长（w_time）', 'gapTimes':u'停顿次数（pause）','stopLines':u'停顿行数','AllUseTime(s)':\\\n",
    "                     u'所有使用时间总用水时长（s）','WashHour':u'洗浴时间点','UseTime':u'用水时长（use_water_time）','GapTime':\\\n",
    "                    u'总停顿时长（w_pause_time）','w_water':u'总用水量（w_water）','flow_volatility':u'水流量波动（flow_volatility）',\\\n",
    "                   'water_rate':u'平均水流量（water_rate）','use_water_rate':u'用水/总时长（use_water_rate）','avg_pause_time':\\\n",
    "                    u'平均停顿时长（avg_pause_time）','pause_volatility':u'停顿时长波动（pause_volatility）'},inplace='True' )\n",
    "\n",
    "fdf2.index.name=u'事件编号'\n",
    "fdf2.to_excel('attrConst_results.xlsx')\n",
    "fdf2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>起始数据编号</th>\n",
       "      <th>终止数据编号</th>\n",
       "      <th>开始时间</th>\n",
       "      <th>结束时间</th>\n",
       "      <th>总用水时长（w_time）</th>\n",
       "      <th>停顿次数（pause）</th>\n",
       "      <th>停顿行数</th>\n",
       "      <th>所有使用时间总用水时长（s）</th>\n",
       "      <th>洗浴时间点</th>\n",
       "      <th>用水时长（use_water_time）</th>\n",
       "      <th>总停顿时长（w_pause_time）</th>\n",
       "      <th>总用水量（w_water）</th>\n",
       "      <th>水流量波动（flow_volatility）</th>\n",
       "      <th>平均水流量（water_rate）</th>\n",
       "      <th>停顿时长波动（pause_volatility）</th>\n",
       "      <th>用水/总时长（use_water_rate）</th>\n",
       "      <th>平均停顿时长（avg_pause_time）</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>事件编号</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>410</td>\n",
       "      <td>593</td>\n",
       "      <td>2014-10-19 15:34:38</td>\n",
       "      <td>2014-10-19 15:48:47</td>\n",
       "      <td>00:14:09</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>849.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>835.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>337.90</td>\n",
       "      <td>0.637375</td>\n",
       "      <td>40.467066</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.983510</td>\n",
       "      <td>14.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>659</td>\n",
       "      <td>765</td>\n",
       "      <td>2014-10-19 17:23:20</td>\n",
       "      <td>2014-10-19 17:34:37</td>\n",
       "      <td>00:11:17</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>677.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>506.0</td>\n",
       "      <td>171.0</td>\n",
       "      <td>150.62</td>\n",
       "      <td>1.788448</td>\n",
       "      <td>29.766798</td>\n",
       "      <td>2209.0</td>\n",
       "      <td>0.747415</td>\n",
       "      <td>85.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>772</td>\n",
       "      <td>922</td>\n",
       "      <td>2014-10-19 17:46:20</td>\n",
       "      <td>2014-10-19 17:55:05</td>\n",
       "      <td>00:08:45</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>525.0</td>\n",
       "      <td>17.0</td>\n",
       "      <td>525.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>134.16</td>\n",
       "      <td>0.841975</td>\n",
       "      <td>25.554286</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      起始数据编号  终止数据编号                开始时间                结束时间 总用水时长（w_time）  \\\n",
       "事件编号                                                                         \n",
       "6        410     593 2014-10-19 15:34:38 2014-10-19 15:48:47      00:14:09   \n",
       "8        659     765 2014-10-19 17:23:20 2014-10-19 17:34:37      00:11:17   \n",
       "9        772     922 2014-10-19 17:46:20 2014-10-19 17:55:05      00:08:45   \n",
       "\n",
       "      停顿次数（pause）  停顿行数  所有使用时间总用水时长（s）  洗浴时间点  用水时长（use_water_time）  \\\n",
       "事件编号                                                                   \n",
       "6               1     2           849.0   15.0                 835.0   \n",
       "8               2     3           677.0   17.0                 506.0   \n",
       "9               0     0           525.0   17.0                 525.0   \n",
       "\n",
       "      总停顿时长（w_pause_time）  总用水量（w_water）  水流量波动（flow_volatility）  \\\n",
       "事件编号                                                               \n",
       "6                    14.0         337.90                0.637375   \n",
       "8                   171.0         150.62                1.788448   \n",
       "9                     0.0         134.16                0.841975   \n",
       "\n",
       "      平均水流量（water_rate）  停顿时长波动（pause_volatility）  用水/总时长（use_water_rate）  \\\n",
       "事件编号                                                                        \n",
       "6             40.467066                       0.0                0.983510   \n",
       "8             29.766798                    2209.0                0.747415   \n",
       "9             25.554286                       NaN                1.000000   \n",
       "\n",
       "      平均停顿时长（avg_pause_time）  \n",
       "事件编号                          \n",
       "6                       14.0  \n",
       "8                       85.5  \n",
       "9                        0.0  "
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#-----第*4*步-----接下来进行数据处理和筛选得到“候选洗浴事件，用于接下来的模型构建\n",
    "# 去掉  用水时长小于100秒\n",
    "# 去掉 总用水时长小于120秒\n",
    "# 去掉 一次用水事件中总用水量(纯热水)小于10升\n",
    "data_filter = fdf2[(fdf2[u'所有使用时间总用水时长（s）']>=120)  & (fdf2[u'总用水量（w_water）']>=10) & (fdf2[u'用水时长（use_water_time）']>=100)]\n",
    "data_filter.to_excel('data_filter.xlsx')\n",
    "# data_filter.iloc[:3]\n",
    "data_filter.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
